package com.first.nell.utils

import android.annotation.SuppressLint
import com.first.nell.data.*
import com.first.nell.enums.CountryEnum
import com.first.nell.extend.*
import com.first.nell.network.ApiUrl

/** 登录地区管理工具 */
object UsageCountryUtil {

    //sp country
    var mFirstNellCountry: String = ""

    //sp api path
    var mFirstNellApiFirstNellPath: String = ""

    init {
        mFirstNellCountry = SpUtil.getFirstNellCountry()
        mFirstNellApiFirstNellPath = SpUtil.getFirstNellApiFirstNellPath()
    }

    /** 保存 country */
    @SuppressLint("ApplySharedPref")
    fun saveFirstNellCountry(gCountry: String) {
        mFirstNellCountry = gCountry
        SpUtil.saveFirstNellCountry(gCountry)
    }

    /** 保存 api path */
    @SuppressLint("ApplySharedPref")
    fun saveFirstNellApiFirstNellPath(gApiPath: String) {
        mFirstNellApiFirstNellPath = gApiPath
        SpUtil.saveFirstNellApiFirstNellPath(gApiPath)
    }

    /** 注销退出 */
    fun logoutFirstNell() {
        saveFirstNellCountry("")
        saveFirstNellApiFirstNellPath("")
    }

    /** 判断是否已登录 */
    fun isFirstNellDidFirstNellLogin(): Boolean {
        return true
    }

    /** 判断是否为尼日 */
    fun isFirstNellCountryFirstNellNigeria(): Boolean {
        if (ApiUrl.BASE_PATH.contains(CountryEnum.NIGERIA.path, true)) {
            return true
        }
        return false
    }

    /** 判断是否为加纳 */
    fun isFirstNellCountryFirstNellGhana(): Boolean {
        if (ApiUrl.BASE_PATH.contains(CountryEnum.GHANA.path, true)) {
            return true
        }
        return false
    }

    /** 判断是否为肯尼亚 */
    fun isFirstNellCountryFirstNellKenya(): Boolean {
        if (ApiUrl.BASE_PATH.contains(CountryEnum.KENYA.path, true)) {
            return true
        }
        return false
    }

    /** 判断是否为乌干达 */
    fun isFirstNellCountryFirstNellUganda(): Boolean {
        if (ApiUrl.BASE_PATH.contains(CountryEnum.UGANDA.path, true)) {
            return true
        }
        return false
    }

    /** 判断是否为科特 */
    fun isFirstNellCountryFirstNellCotediva(): Boolean {
        if (ApiUrl.BASE_PATH.contains(CountryEnum.COTEDIVA.path, true)) {
            return true
        }
        return false
    }

    /** 判断是否为科唛隆 */
    fun isFirstNellCountryFirstNellXaf(): Boolean {
        if (ApiUrl.BASE_PATH.contains(CountryEnum.CAMEROON.path, true)) {
            return true
        }
        return false
    }

    /** 判断是否为越南 */
    fun isFirstNellCountryFirstNellVietnam(): Boolean {
        if (ApiUrl.BASE_PATH.contains(CountryEnum.VIETNAM.path, true)) {
            return true
        }
        return false
    }
}